package com.jusntow.question10;

import java.util.ArrayList;
import java.util.List;

/**
 * @author justnow
 * Created on 2020-10-28
 * Description
 */
public class Demo {
    public static void main(String[] args) {
        new Thread(() -> {
            List list = new ArrayList();
            int i = 1;
            while (i <= 10) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "执行第" + i++ + "次");
                byte[] bytes = new byte[1024 * 1024 * 1024];
                list.add(bytes);
            }
        }, "theadA").start();

        new Thread(() -> {
            int i = 1;
            while (i <= 10) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "执行第" + i++ + "次");
            }
        }, "threadB").start();
    }
}
